package com.cheer.enums;

import java.util.Objects;

/**
 * @author lx
 */
public enum RoleEnum {

    ADMIN(1, "管理员"),
    USER(2, "用户");

    private Integer code;
    private String message;

    RoleEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static String codeToName(Integer code) {
        for (RoleEnum roleEnum : RoleEnum.values()) {
            if (Objects.equals(roleEnum.getCode(), code)) {
                return roleEnum.name().toUpperCase();
            }
        }
        return null;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}
